package com.test.mooan.labama.dialog_boom;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.test.mooan.labama.R;
import com.test.mooan.labama.bean_boom.process_boom.ProcessInfo_boom;
import com.test.mooan.labama.utils_boom.helper_boom.UserInfoHelper_boom;


public class HolidayDialog_boom extends Dialog {

    private final String pageTag = "DIALOG_HOLIDAY";

    private final Runnable applyNowRunnable;

    public HolidayDialog_boom(@NonNull Context context, Runnable applyNowRunnable) {
        super(context);
        this.applyNowRunnable = applyNowRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_holiday_boom);
        initView();
    }

    @SuppressLint("SetTextI18n")
    private void initView(){

        getWindow().setBackgroundDrawableResource(R.color.trans);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        TextView daysTv = findViewById(R.id.dialog_holiday_tv_days);
        TextView rateTv = findViewById(R.id.dialog_holiday_tv_rate);

        daysTv.setText(ProcessInfo_boom.getInstance().gHwDays());
        rateTv.setText(ProcessInfo_boom.getInstance().gHwRate());

        findViewById(R.id.dialog_holiday_close).setOnClickListener(v -> {
            UserInfoHelper_boom.gInstance().addEventPoint(pageTag+"_CLOSE_CLICK");
            dismiss();
        });

        findViewById(R.id.dialog_holiday_btn_apply).setOnClickListener(v -> {
            UserInfoHelper_boom.gInstance().addEventPoint(pageTag+"_APPLY_NOW_CLICK");
            dismiss();
            if (applyNowRunnable!=null) applyNowRunnable.run();
        });

    }

    @Override
    public void show() {
        super.show();
        UserInfoHelper_boom.gInstance().addEventPoint(pageTag+"_START");
    }

    @Override
    public void dismiss() {
        super.dismiss();
        UserInfoHelper_boom.gInstance().addEventPoint(pageTag+"_END");
    }

}
